<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html" 
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:define name="corpo">
        <div class="page-header">
            <h1><small>Financeiro - Visualizador de faturas</small></h1>
        </div>
        <ol class="breadcrumb">
            <li>Home</li>
            <li>Financeiro</li>
            <li class="active">Fatura</li>
        </ol>
        
            <h:form id="form_upload" enctype="multipart/form-data">
                <p:growl id="growl" showDetail="true" life="6000"/>
                <p:fileUpload fileUploadListener="#{controllerFatura.handleFileUpload}" 
                              mode="advanced" auto="true" sizeLimit="1000000" multiple="false"
                              allowTypes="/(\.|\/)(pdf)$/" update="growl,:form_listagem:tabela" label="Procurar..."/>
            </h:form>
            <br/>
        
        
        <h:form id="form_listagem">
            <p:dataTable id="tabela" var="p" value="#{controllerFatura.listaDM}" emptyMessage="Nenhuma fatura nos registros..."
                             paginator="true" rows="10"  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
                <p:column headerText="ID" styleClass="centralizar-texto">
                    <h:outputText value="#{p.id}"/>
                </p:column>
                <p:column headerText="MD5" styleClass="centralizar-texto">
                    <h:outputText value="#{p.md5}"/>
                </p:column>
                <p:column headerText="Mês de referência" styleClass="centralizar-texto">
                    <h:outputText value="#{p.data_mes_referencia}">
                        <f:convertDateTime pattern="MM/YYYY"/>
                    </h:outputText>
                </p:column>
                <p:column headerText="Arquivo" styleClass="centralizar-texto">
                    <ui:remove>
                        <p:commandButton value="Ziped" ajax="false" icon="ui-icon-arrowthichk-s">
                            <p:fileDownload value="#{controllerFatura.fileDownloadZiped()}"/>
                        </p:commandButton>
                    </ui:remove>
                    <p:commandButton value="download" ajax="false" icon="ui-icon-arrowreturnthick-1-s" style="width: 150px;">
                        <p:fileDownload value="#{controllerFatura.fileDownloadUnziped()}"/>
                    </p:commandButton>
                    
                    <p:commandButton actionListener="#{controllerFatura.remover()}" image="ui-icon-trash" update=":form_listagem"/>
                    
                </p:column>
           </p:dataTable>
        </h:form>       
    </ui:define>
</ui:composition>